{% extends "options.html" %}

{% block jsfuncs %}

del_page = function(cache_id) {
	var log = $('load_img').setStyles({'display':'inline'});
	
	var req = new Request.HTML({ 	url: '/admin/options/cache/del',
	 									  	method: 'post',
										  	evalScripts : true,
										  	data: 'id=' + cache_id,
											onComplete: function(e) {
												log.setStyles({'display':'none'});
											}
										}).send();
	return false;
	
};

$('clear_cache').addEvent('click', function(e) {
	new Event(e).stop();
	
	var log = $('load_img').setStyles({'display':'inline'});
   
	var req = new Request.HTML({ 	url: '/admin/cache/del',
	 									  	method: 'post',
										  	evalScripts : true,
										  	data: 'action=del_cache',
											onComplete: function(e) {
												log.setStyles({'display':'none'});
											}
										}).send();
	return false;
});

{% endblock %}

{% block content %}
<h3>缓存网页</h3>
<div id="cache_list">
<table id="cache_table">
{% if cached_pages.count %}
		<tr>
		<td class="td_button"></td>
		<th>路径</th>
		<th class="td_date">时间</th>
		</tr>
	{% for page in cached_pages %}
		<tr id="{{page.key}}">
			<td class="td_button"><a href="#" onclick="javascript:del_page('{{page.key }}');" class="del_link">删除</a></td>	
			<td class="">{{ page.key.name }}</td>
			<td class="td_date">{{ page.created|datetz:"d/m/Y H:i" }}</td>
	{% endfor %}

{%else%}
	<h4>没有缓存的网页</h4>
{% endif %}
</table>
</div>
<div>
<a href="#" id="clear_cache" class="new">清除所有缓存网页</a><img src="/static/images/loading.gif" style="display:none;" id="load_img" />
</div>

{% endblock %}